// Town script for town 23: Senarti temple

begintownscript;

variables;

int x,i,j,choice;

body;

beginstate INIT_STATE;

	if (get_flag(23,0) == 1)
			set_flag(23,0,0);
		
break;

beginstate EXIT_STATE;
break;

beginstate START_STATE;
break;

beginstate 10;
if (get_flag(23,0) == 0) {
	if (species_in_party(2) == 1) {
		reset_dialog();
		add_dialog_str(0,"This is something you hadn't foreseen. You have a Nephil in your party, who found a sort of mechanism behind these crossed swords. Its a lever.",0);
		add_dialog_str(1,"Having a Nephil in your party is extremely handy in this place. Because of the Senarti being cats, like Nephilim, you have a major advantage. Your Nephil party member can find things your other party members can't.",0);
		add_dialog_str(2,"Would you like to pull the lever?",0);
		add_dialog_choice(0,"Pull the lever");
		add_dialog_choice(1,"Leave it");
		choice = run_dialog(0);
		
		if (choice == 1) {
				message_dialog("You pull the lever. You hear the sound of grinding gears, and the wall next to you slides open.","The wall reveals a hidden passage.");
				set_terrain(21,27,0);
				set_flag(23,0,1);
				}
		}
	}
break;

beginstate 11;
if (get_flag(23,1) == 1) 
		end();
	message_dialog("The Senarti, being a race that not long ago came to existence, amazingly enough already have a secret cult.","All floors are laid with small stones, probably coming from the cave walls. They form beautiful patterns in this beautiful temple.");
	set_flag(23,1,1);
break;

beginstate 12;
if (get_flag(23,2) == 1) 
		end();
	message_dialog("As soon as you step on the space between the two barriers, you hear a sound made by some sort of flash. After that you hear growling. You probably activated a magical trap.","");
	activate_hidden_group(6);
	set_flag(23,2,1);
break;

beginstate 13;
if (get_flag(23,3) == 1) 
		end();
	message_dialog("This temple is absolutely beautiful. A red carpet splits in the middle of the room, one half to the altar, the other to a door. Six big pillars support the ceiling.","This construction is huge. You can't believe it took them only several months to build this temple.");
	message_dialog("As you look around, you see just one thing that ruins the atmosphere: its a huge hole in the wall. You wonder what caused it.","");
	set_flag(23,3,1);
break;

beginstate 14;
if (get_flag(23,4) == 1) 
		end();
	message_dialog("The corridor is very silent and eerie. Its probably some sort of meditation room. Do you want to disturb the peace here?","");
	set_flag(23,4,1);
break;

beginstate 15;
if (get_flag(23,5) == 1) 
		end();
	message_dialog("The corridor is very silent and eerie. Its probably some sort of meditation room. Do you want to disturb the peace here?","");
	set_flag(23,5,1);
break;

beginstate 16;
if (get_flag(23,6) == 1) 
		end();
	message_dialog("The way this hallway looks is already quite different from what you are used to. Instead of the normal floor tiles, the floor is tiled with nice white marble stones.","");
	set_flag(23,6,1);
break;

beginstate 17;
reset_dialog();
add_dialog_str(0,"The book on this pedestal is old. The pages are yellow and slightly wrinkled from water dripping on it. Would you like to read it?",0);
add_dialog_choice(0,"Read the book");
add_dialog_choice(1,"Leave it");
choice = run_dialog(0);
	
	if (choice == 1) {
			set_state_continue(28);
			}
break;

beginstate 18;
if (party_has_trait(22) == 1) {
		message_dialog("This book contains descriptions of all Senarti rituals that are done in this temple. One of the rituals catches your eye. Its called _Ritual of Sanctification._ It looks quite difficult.","You already learned this ritual. You close the book and stand up. Learning it a second time would be a waste of time.");
		end();
		}
	message_dialog("This book contains descriptions of all Senarti rituals that are done in this temple. One of the rituals catches your eye. Its called _Ritual of Sanctification._ It looks quite difficult.","You sit and read the ritual. You memorise it well. You now have the character trait Ritual of Sanctification.");
	
	j = get_selected_pc();
	i = 0;
	
	while (i < 4) {
		if (((j < 0) || (j == i)) && (char_ok(i))) {
				set_char_trait(i,22,1);
			}
			i = i + 1;
		}
break;

beginstate 19;
	message_dialog("The book is closed and sealed off with a lock. You can't break it open. The book glows slightly. Its magically protected.","");
break;

beginstate 20;
	message_dialog("Once a book had lain here. Now its gone. You wonder what happened to it. Maybe the book got damaged, and had to be repaired or something.","");
break;

beginstate 21;
	message_dialog("The book on this pedestal has a sort of story in it. Its all in the Senarti tongue, so you don't understand it, but the pictures tell you the story is about some Senarti leader. The book doesn't tell you more.","");
break;

beginstate 22;
if (get_flag(23,7) == 1) 
		end();
	message_dialog("This room has been elegantly tiled with green floor tiles. Six pedestals, with four books on them, stand on each side of the room.","");
	set_flag(23,7,1);
break;

beginstate 24;
if (get_flag(23,8) == 1) 
		end();
	message_dialog("You get the creeps from this place. All around you are these black marble walls, with strange blue runes at the bottom of them. It all looks very scary, but its certainly beautiful.","");
	set_flag(23,8,1);
break;

beginstate 25;
if (get_flag(23,9) == 1) {
		message_dialog("You stand again at the altar. The light that at first surrounded it faded. You don't dare to kneel at it again. You back away","");
		end();
		}
	reset_dialog();
	add_dialog_str(0,"This big, black marble altar is faintly glowing. A force pulls you down. The altar wants you to kneel. Do you?",0);
	add_dialog_choice(0,"Kneel and pray");
	add_dialog_choice(1,"Keep standing");
	choice = run_dialog(0);
	
	if (choice == 1) {
			message_dialog("You kneel down and start praying. Soon a voice begins to speak in your heads.","_You are no Senarti! The big San-Martu doesn't tolerate this! You, foolish creatures, will be punished for your deeds!_");
			message_dialog("It remains silent for some time. You keep kneeling. Soon, you hear flashes, and a light blinds you.","");
			
			// monsters appearing

				x = 86;

				place_monster(19,8,60,0);
				put_boom_on_char(x,2,0);
				set_character_facing(x,2);
				run_animation_sound(54);
				
				x = x + 1;
				
				place_monster(19,10,60,0);
				put_boom_on_char(x,2,0);
				set_character_facing(x,2);
				run_animation_sound(54);
			
			message_dialog("This doesn't look to good. After a few moments, an enormous pain runs through your body.","");
			
			// loosing health
			
			change_char_health(0,-80);
			change_char_health(1,-80);
			change_char_health(2,-80);
			change_char_health(3,-80);
			change_char_health(4,-80);
			change_char_health(5,-80);
			
			message_dialog("The situation is really getting desperate. Not only are you facing two dangerous demons, now you also lost health. So what else can go wrong?","");
			
			// gates closing
					
			flip_terrain(23,24);
			flip_terrain(24,24);
			run_animation_sound(99);
			pause(15);
			
			message_dialog("Oh good. So now you are also locked up in this place, having two monsters two deal with, and can barely stand straight because of the pain. Its all just fine!","So good luck with fighting the monsters then!");
			set_flag(23,9,1);
			}
break;

beginstate 26;
	message_dialog("When you look deep into this crystal, you see a top down view of the temple. It looks like some sort of device to help catch intruders.","Intruders like you.");
break;

beginstate 27;
if (get_flag(23,10) == 1) 
		end();
	message_dialog("You found a secret door behind the priest's preparation rooms. You see a crystal and a big iron lever. You wonder what they do.","");
	set_flag(23,10,1);
break;

beginstate 28;
message_dialog("This book is one of the Senarti _Bibles._ You open the book, flip through it, and then put it back. It is of no use for you. However, before putting it back, you stop at a page with a picture on it. It is a drawing of a cat.","The cat is big, has glowing eyes, and a huge bow. This must be the Senarti god. The name under it says _San Martu._");
break;

beginstate 29;
message_dialog("You stare in the darkness, trying to see where this path will lead you. You can see nothing but darkness. It might be a bad idea to go up the path, so you eventually decide to just stay where you are.","");
block_entry(1);
break;
